﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BasePlatformNet;
using BasePlatformCommon;

namespace L9SubSet {
    public partial class Form_LampUID : Form {
        public Form_LampUID(BaseCoreNet core) {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterParent;

            this.core = core;
        }

        private BaseCoreNet core;

        private string section = "LampUID";									// 多语言文件配置节名称

        private void Form_UID_Load(object sender, EventArgs e) {
            
        }

        private void btnSend_Click(object sender, EventArgs e) {
            try
            {
                var uid = Tools.StringToHexByte(tbUID.Text.Trim());
                if (uid != null && uid.Length == 6)
                {
                    core.setLampUID(1, 1, 1, uid);
                    var msg = "写入成功";
                    if (LanguageOper.available) 
                    {
                        msg = LanguageOper.ReadValue(section, "msgStr.1");
                    }
                    Tools.ShowTipMessage(this, msg);
                }
                else 
                {
                    var msg = "写入失败";
                    if (LanguageOper.available)
                    {
                        msg = LanguageOper.ReadValue(section, "msgStr.2");
                    }
                    Tools.ShowErrorMessage(this, msg);
                }
            }
            catch (Exception)
            {
                var msg = "写入失败";
                if (LanguageOper.available)
                {
                    msg = LanguageOper.ReadValue(section, "msgStr.2");
                }
                Tools.ShowErrorMessage(this, msg);
            }
            tbUID.SelectAll();
            tbUID.Focus();
        }

        public void setLanguageText() {
            this.Text = LanguageOper.ReadValue(section, "LampUID.Text");
            btnSend.Text = LanguageOper.ReadValue(section, "btnSend.Text");
        }
    }


}
